<template>
	<view>
		<van-pull-refresh v-model="loading" @refresh="onRefresh" success-text="刷新成功" loading-text="正在加载数据">
		  <view class="product_content">
		  	<productList :proList="productData"></productList>
		  </view>
		</van-pull-refresh>
	</view>
</template>

<script>
	import productList from '../../components/productList/productList.vue';
	import {ref,onMounted} from 'vue';
	import {showToast} from 'vant';
	export default {
		components:{productList},
		setup(){
			const productData = ref ([]);
			 const loading = ref(false);
			 
			 const getProList = (sum)=>{
				 if(uni.getStorageSync('collectList')){
				 	productData.value = JSON.parse(uni.getStorageSync('collectList'))
				 }
			 }
			 
			 onMounted(() =>{
			 	getProList()	
			 })
			 
			 const onRefresh = () => {
			 	 productData.value = []
			 	  showToast({
			 		  duration:500,
			 		  message:'正在加载...',
			 		  forbidClick:true
			 	  });
			 	  setTimeout(() =>{
			 		 getProList()		  
			 		 loading.value = false 
			 	  },1000)
			 };
			 
			 return {
				 productData,
				 loading,
				 onRefresh
			 }
		}
	}
</script>

<style lang="scss" scoped>
 .product_content{
	 min-height: 100vh;
	 padding: 10px 12px;
	 
 }
</style>
